package com.luobo.rest;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.luobo.entity.Guanka;
import com.luobo.entity.News;
import com.luobo.entity.Question;
import com.luobo.entity.Tujian;
import com.luobo.service.BuluoDao;

/**
 * Task的Restful API的Controller.
 * 
 * @author guolei
 */
@Controller
@RequestMapping(value = "/api/v1/buluo")
public class BuluoRestController {

	@Resource
	private BuluoDao buluoDao;

	
	@RequestMapping(value = "guanka/{page}",method = RequestMethod.GET)
	@ResponseBody
	public List<Guanka> listGuanka(@PathVariable("page") Integer page) {
		if(page == null || page <= 0){page = 1;}
		return buluoDao.getGuanKaList(page);
	}
	@RequestMapping(value = "video/{page}",method = RequestMethod.GET)
	@ResponseBody
	public List<Guanka> listVideo(@PathVariable("page") Integer page) {
		if(page == null || page <= 0){page = 1;}
		return buluoDao.getVideoList(page);
	}
	@RequestMapping(value = "news/{page}",method = RequestMethod.GET)
	@ResponseBody
	public List<News> listNews(@PathVariable("page") Integer page){
		if(page == null || page <= 0){page = 1;}
		return buluoDao.getNewsList( page);
	}
	@RequestMapping(value = "tujian",method = RequestMethod.GET)
	@ResponseBody
	public List<Tujian> listTujian(){
		return buluoDao.getTujianList();
	}
	@RequestMapping(value = "question/{page}",method = RequestMethod.GET)
	@ResponseBody
	public List<Question> listQuestion(@PathVariable("page") Integer page){
		if(page == null || page <= 0){page = 1;}
		return buluoDao.getQuestionList(page);
	}
	
}